<?php


namespace Modules\Cms\Http\Controllers\Web;


use App\Helpers\ViewHelpers;
use App\Http\Controllers\MyController;
use Modules\Cms\Http\Requests\ArticleCommentRequest;
use Modules\Cms\Models\Article;
use Modules\Cms\Models\ArticleCategory;
use Modules\Cms\Models\ArticleComment;
use Modules\Cms\Models\ArticleTag;
use Addons\Ads\Models\Ads;
use Illuminate\Http\Request;
use App\Models\UserInfo;
use Illuminate\Support\Facades\Auth;
use App\Models\ArticleHonor;
use App\Models\UserHonor;
use Modules\User\Models\UserPoint;
class ZhenController extends MyController
{

    use ViewHelpers;

    public function index($id)
    {
        session([
            'the_page' => 'z',
            'page_title' => "证书页面",
        ]);
        $uid=Auth::check()?auth()->user()->id:0;
        $point=UserPoint::where('user_id', $uid)->where('aid',$id)->sum('point')?:0;
        $list=ArticleHonor::where('single_id',$id)->orderBy('id','desc')->get();
        foreach ($list as $k=>$v){
         $v->iszheng=UserHonor::where('user_id',$uid)->where('single_id',$id)->where('honor_id',$v->id)->first()?1:0;
        }
        $p=$point?$point->after:0;
        return $this->theme('zheng',['list'=>$list,'point'=>$p,'id'=>$id]);
    }
   
}
   
